

package gov.nbcs.govp.jcsj.ui.thread;

import com.foundercy.pf.control.FPageRoller;
import com.foundercy.pf.control.Rollable;
import com.foundercy.pf.control.table.FTable;
import com.foundercy.pf.gl.dao.ConditionObj;

import com.foundercy.pf.util.FPaginationDTO;

import gov.nbcs.govp.common.bean.PageListBean;


import gov.nbcs.govp.common.util.PlatformTools;
import gov.nbcs.govp.jcsj.ibs.IGPEleBaseBusiness;
import gov.nbcs.govp.jcsj.ui.UIBrand;
import java.awt.Component;
import java.awt.Cursor;
import java.util.List;


public class GovpPpLoadPage extends Thread implements Rollable {
	
	private UIBrand panel;

	private FPaginationDTO page;
	private FPageRoller pageRoller;
	String find_sql="";

	private IGPEleBaseBusiness EleBusiness;

	
	public GovpPpLoadPage(UIBrand panel,IGPEleBaseBusiness EleBusiness,FPageRoller pageRoller,String find_sql){
		this.panel = panel;
		this.EleBusiness=EleBusiness;
		this.find_sql=find_sql;
		this.pageRoller = pageRoller;
		
	}
	public void run() {

		if (pageRoller.getTotalRows() == 0) {
			pageRoller.setPageRows(new FPaginationDTO().getPagecount());
			pageRoller.setRollable(this);
		} else {
			pageRoller.addRollable(this);
			pageRoller.onJump(pageRoller.getCurrentPageIndex());
		}

	}

	public int jump(int pageIndex, int pageRows) {
		// TODO Auto-generated method stub

		try {
		

			panel.setCursor(new Cursor(Cursor.WAIT_CURSOR));
			FPaginationDTO page = new FPaginationDTO();
			page.setCurrpage(pageIndex);
			page.setPagecount(pageRows);

			ConditionObj obj = new ConditionObj();
			FTable table = panel.getOperationTable();

			Component c = PlatformTools.replaceTableAsDoing(table);
			PageListBean pagelist = EleBusiness.getPpdetail(page, find_sql);

			List list = pagelist.getDataList();
			PlatformTools.replaceTableAsDone(c, table);
			table.setData(list);
			panel.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
			return pagelist.getTotalrows();
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			return 0;
		}
	}


}
